//
//  ByViewDoctorMyHeader.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/18.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByViewDoctorMyHeader.h"
@implementation ByViewDoctorMyHeader
{
    UIImageView         *_bgImg;
    UIImageView         *_icon;
    UILabel             *_nickNameLabel;
}
- (instancetype)init{
    if (self = [super init]) {
        [self createViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)createViews{
    _bgImg = [[UIImageView alloc] init];
    [self addSubview:_bgImg];
    [_bgImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.top.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 250));
    }];
    _bgImg.image = [UIImage imageNamed:@"My_beijing"];
    
    // 头像
    _icon = [[UIImageView alloc] init];
    [self addSubview:_icon];
    [_icon mas_makeConstraints:^(MASConstraintMaker *make) {
        if (SCREEN_HEIGHT == 812) {
            make.top.equalTo(@(88 + 10));
        }else{
            make.top.equalTo(@(64 + 15));
        }
        make.centerX.equalTo(self.mas_centerX);
        make.size.mas_equalTo(CGSizeMake(70, 70));
    }];
    _icon.layer.cornerRadius = 70 / 2;
    UITapGestureRecognizer *iconTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap)];
    _icon.userInteractionEnabled = YES;
    [_icon addGestureRecognizer:iconTap];
    
    // 昵称
    CGFloat width = [@"用户名" getSizeOfString:14].width + 15;
    _nickNameLabel = [[UILabel alloc] init];
    [self addSubview:_nickNameLabel];
    [_nickNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@((SCREEN_WIDTH - 30 - width) / 2));
        make.top.equalTo(_icon.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(width, 20));
    }];
    _nickNameLabel.font = FONT(14);
    _nickNameLabel.textColor = [UIColor whiteColor];
    UITapGestureRecognizer *nameTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(clickTap)];
    _nickNameLabel.userInteractionEnabled = YES;
    [_nickNameLabel addGestureRecognizer:nameTap];
    
}


- (void)setModel:(ByModelUser *)model{
    _model = model;
    
    // 测试数据
    _model.username = @"测试测试昵称";
    _icon.backgroundColor = [UIColor redColor];
    _nickNameLabel.text = _model.username;
    
    // 昵称
    CGFloat width = [_model.username getSizeOfString:14].width + 15;
    [_nickNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@((SCREEN_WIDTH - 30 - width) / 2));
        make.top.equalTo(_icon.mas_bottom).offset(10);
        make.size.mas_equalTo(CGSizeMake(width, 20));
    }];
    
}


- (void)clickTap{
   
}
@end
